2025-11-04 call-by-name vs call-by-value

Call-by-name

So far, we’ve been using call-by-name (CBN), where variables represent terms. This means that the argument to a function doesn’t have to be resolved before being given to the function.

Call-by-value (CBV)

Where variables represent values. So before binding anything, it has to be reduced down to a value first.


Impact of choice

Evaluation order does not affect pure results.

The difference is only noticeable if the program has effects.

Most languages with effects are call-by-value.

Haskell is call-by-need, which is an optimised variant of call-by-name.

Call-by-value lambda calculus

Our statics don’t need to be changed, since they only affect typing and not evaluation order.

Any dynamic that uses substitution will need to be changed such that the thing being substituted in is a value.

We also need to add some rules to allow us to step towards the arguments being values.

Effects

To see the impact of CBV vs CBN we will add a simple effect: print.